package com.guoqi.bridgedemo

import android.app.Application
import android.util.Log
import com.tencent.smtt.sdk.QbSdk
import com.tencent.smtt.sdk.TbsListener

/**
 *  作者    GUOQI
 *  时间    2019/2/12 13:28
 *  描述
 */
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        initX5WebView()
    }

    private fun initX5WebView() {
        QbSdk.initX5Environment(this, object : QbSdk.PreInitCallback {
            override fun onCoreInitFinished() {
            }

            override fun onViewInitFinished(b: Boolean) {
                Log.e("X5WebView", "initX5WebView() b=$b，[b=true说明内核初始化并可以使用]")
            }

        });
        QbSdk.setDownloadWithoutWifi(true)
        QbSdk.setTbsListener(object : TbsListener {
            override fun onInstallFinish(p0: Int) {
                //内核安装完成回调，
                Log.e("X5WebView", "内核安装完成")
            }

            override fun onDownloadFinish(p0: Int) {
                //tbs内核下载完成回调
                Log.e("X5WebView", "tbs内核下载完成回调")
            }

            override fun onDownloadProgress(p0: Int) {
                //下载进度监听
                Log.e("X5WebView", "下载$p0%")
            }
        })
    }
}